package com.example.orcaltest.service.impl;

import com.example.orcaltest.entity.PbcgzGzdytb;
import com.example.orcaltest.entity.PbcgzGzdytbDTO;
import com.example.orcaltest.mapper.PbcgzGzdytbMapper;
import com.example.orcaltest.service.IPbcgzGzdytbService;
import com.example.orcaltest.utils.PbcgzUtil;
import com.example.orcaltest.utils.UUIDGenerator;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PbcgzGzdytbServiceImpl implements IPbcgzGzdytbService {

    @Autowired
    private PbcgzGzdytbMapper pbcgzGzdytbMapper;
    
    @Override
    public List<PbcgzGzdytb> list(PbcgzGzdytbDTO dto) {
        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
        dto.setUserId(PbcgzUtil.getLoadUserID());
        dto.setOrgId(PbcgzUtil.getLoadOrgId());
        dto.setUserName(PbcgzUtil.getLoginUserInfo().getFullName());
        List<PbcgzGzdytb> pbcgzGzdytbs = pbcgzGzdytbMapper.selectList(dto);
        return pbcgzGzdytbs;
    }

    @Override
    public void add(PbcgzGzdytb record) {
        record.setId(UUIDGenerator.radom().toString().replaceAll("-", ""));
        record.setUserId(PbcgzUtil.getLoadUserID());
        record.setOrgId(PbcgzUtil.getLoadOrgId());
        record.setUserName(PbcgzUtil.getLoginUserInfo().getFullName());
        record.setStatus("0");
        record.setOrgName(PbcgzUtil.getLoadOrgName());
        pbcgzGzdytbMapper.insert(record);
    }

    @Override
    public void update(PbcgzGzdytb record) {
        pbcgzGzdytbMapper.update(record);
    }

    @Override
    public void batchDelete(List<String> ids) {
        pbcgzGzdytbMapper.batchDelete(ids);
    }

    @Override
    public void batchUpdateStatus(List<String> ids) {
        pbcgzGzdytbMapper.batchUpdateStatus(ids, "1", null);
    }
}